#include "EllapsedTimer.h"
using namespace frost;

EllapsedTimer::EllapsedTimer(void)
{
	timesUp = false;
	running = false;
	timeLeft = 0;
}


EllapsedTimer::~EllapsedTimer(void)
{
}


bool EllapsedTimer::timedOut( void )
{
	return timesUp;
}


void EllapsedTimer::startTimer( int millisekunder )
{
	timeLimit = millisekunder;
	startTid = timeGetTime();
	running = true;
	timesUp = false;
}


void EllapsedTimer::updateTimer( void )
{
		if( timeGetTime() - startTid >= timeLimit )
		{
			timesUp = true;
			running = false;
		}
		timeLeft = (timeLimit - (timeGetTime() - startTid)) / 1000;
}

int EllapsedTimer::GetTimeLeft( void )
{
	return timeLeft;
}

void EllapsedTimer::StoppTimer( void )
{
	running = false;
	timesUp = false;
}

void EllapsedTimer::increaseTime(int millisekunder)
{
	timeLimit += millisekunder;
}
